package com.lfg.leetcode.leetcode1000;


public class No1185dayOfTheWeek {
    private static final String[] WEEK = new String[]{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
    private static final int[] DAY = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30};

    public static void main(String[] args) {
        System.out.println(dayOfTheWeek(31, 8, 2019));
    }

    public static String dayOfTheWeek(int day, int month, int year) {
        int days = day;
        days += (year - 1971) * 365 + (year - 1969) / 4;
        for (int i = 0; i < month-1; i++) {
            days += DAY[i];
        }
        if (month > 2 && (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))) {
            days++;
        }

        return WEEK[(days + 3) % 7];
    }

}



